<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('打印模板列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.addFull()" shiro:hasPermission="system:template:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.editFull()" shiro:hasPermission="system:template:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:template:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:template:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:template:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:template:remove')}]];
        var prefix = ctx + "system/print";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "打印模板",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'id', 
                    title : 'ID',
                    visible: false
                },
                {
                    field : 'remark',
                    title : '模板说明'
                },
                {
                    field : 'type', 
                    title : '模板类别',
                    formatter: function(value, row, index) {
                        var res = '';
                        if(value=='01'){
                            res = '预订';
                        }else if(value=='02'){
                            res = '认购';
                        }else if(value=='03'){
                            res = '合同';
                        }else if(value=='04'){
                            res = '收款信息';
                        }else if(value=='05'){
                            res = '换房';
                        }else if(value=='06'){
                            res = '付款方式变更';
                        }else if(value=='07'){
                            res = '退单';
                        }else if(value=='08'){
                            res = '客户更名';
                        }else if(value=='09'){
                            res = '折扣报批';
                        }else if(value=='10'){
                            res = '认筹';
                        }else if(value=='11'){
                            res = '收据';
                        }
                        return res;
                    }
                },
                {
                    field : 'printMode',
                    title : '打印方式',
                    formatter: function(value, row, index) {
                        var res = '';
                        if(value=='01'){
                            res = '<span class="label label-success">空白纸</span>';
                        }else {
                            res = '<span class="label label-warning">套打</span>';
                        }
                        return res;
                    }
                },
                {
                    field : 'state', 
                    title : '状态',
                    formatter: function(value, row, index) {
                        var res = '';
                        if(value=='0'){
                            res = '<span class="label label-primary">启用</span>';
                        }else {
                            res = '<span class="label label-danger">停用</span>';
                        }
                        return res;
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editFull(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>